home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Steal This CD
/
steal_this_cd.iso
/
Chapter 07 - Where the Hackers Are
/
virc200.exe
/
{app}
/
Scripts
/
sounds.vsc
< prev
next >
Wrap
Text File
|
2003-05-16
|
3KB
|
110 lines
// sounds.vsc - implements CTCP SOUND
// * /sound <filename> to send a sound to the active channel
// * Option: automatically request sounds I don't have
// * Option: automatically send sound files when requested
// * Option: size limit for automatic sound sharing (KB)
Name Sounds for ViRC 2
// Version check
if $exebuild < 114
MessageBox sounds.vsc requires ViRC 2.0rc2 (200/114 or later).
Halt
endif
// Settings
AddScriptControl config check "Play CTCP sounds" sounds_play = 1
AddScriptControl config check "Automatically request sounds I don't have" sounds_request = 1
AddScriptControl config check "Automatically send sound files when requested" sounds_share = 1
AddScriptControl config edit "Size limit for automatic sound sharing (KB)" sounds_sharemaxkb = 25
AddEventSound sounds_unknown "/Sound" "Unknown sound received"
// Aliases
Alias SOUND
// Sound [channel] [filename]
if $ischannel($1)
@l $chan = $1
@l $fn = $2-
else
@l $chan = $C
@l $fn = $1-
endif
if [$fn] == []
ChDir $getpath(sound)
@l $fn = $opendialog(Select a sound file|Sound files (*.wav;*.mid;*.rmi;*.mp3)|*.wav;*.mid;*.rmi;*.mp3|All files (*.*)|*.*)
Halt if [$fn] == []
else if $strpos(\ $fn) == 0
@l $fn = $getpath(sound)$fn
endif
PlaySoundFile $fn
@l $fn = $rstrtokr(\ $fn)
if $strposex(" " $fn)
@l $fn = "$fn"
endif
CTCP $chan SOUND $fn
EndAlias
// Events
Event CTCPSound "% PRIVMSG % :\ASOUND"
@l $requested = $null
if $fileexists($getpath(sound)$4-)
if $getsetting(sounds_play)
PlaySoundFile $4-
endif
else
PlayEventSound sounds_unknown
if $getsetting(sounds_request)
@l $requested = $null (automatically requested)
^Msg $nick !$nick $4-
endif
endif
if $ischannel($2)
TextOut > $2 ecCTCP *** \b$_active(nick $nick)\b plays a sound${requested}: $4-
else
TextOut ecCTCP *** Private sound from \b$_active(nick $nick)\b${requested}: $4-
endif
EndEvent
Event SoundRequest -after -eval "% PRIVMSG % :!$N"
Halt if !$getsetting(sounds_share)
@l $fn = $4-
// strip quotes
if $wildmatch($fn "*")
@l $fn = $substr($fn 2 $($length($fn) - 2))
endif
@l $fn = $getpath(sound)$fn
if $fileexists($fn)
if $getfilesize($fn) <= $(1024 * $getsetting(sounds_sharemaxkb))
DCC Send $nick $fn
else
^Notice $nick Sorry, that file is too big for me to send automatically. ($($getfilesize($fn) / 1024) KB)
endif
endif
EndEvent
// Menus
MenuTree MT_SOUNDS_CHANNELTEXTPOPUP
M_CHANSOUND <none> 0 0 &Sound...
EndMenuTree
MenuItem M_CHANSOUND on MT_SOUNDS_CHANNELTEXTPOPUP
Sound $C
EndMenuItem
MenuHint M_CHANSOUND on MT_SOUNDS_CHANNELTEXTPOPUP = Play a sound file in the channel
MergeMenu MT_SOUNDS_CHANNELTEXTPOPUP after MT_CHANNELTEXTPOPUP